import requests


# Html下载器
class HtmlDownloader:
    def download(self, url, headers):
        """
        根据给定的url下载网页
        @param url:
        @return ：下载好的文本
        """
        result = requests.get(url, headers=headers)
        return result.content.decode("utf-8")
        # return result.request.headers


downloader = HtmlDownloader()
headers = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"}
result = downloader.download("https://www.mi.com/",headers)
print(result)
